{% extends 'base.html' %}
{% block title %}定时任务{% endblock %}
{% block content %}
    <div class="span9" id="content">
        <div class="block">
            <div class="navbar navbar-inner block-header">
                <div class="muted pull-left">定时任务</div>
            </div>
            <h4>{{ msg }}</h4>
            {% if messages %}
                <div class="messages" style="margin-left: 10px">
                    {% for message in messages %}
                        <p {% if message.tags %} class="{{ message.tags }}"{% endif %} style="color:red">{{ message }}</p>
                    {% endfor %}
                </div>
            {% endif %}
            <div class="block-content collapse in">
                <div class="span12">
                    <div class="table-toolbar">
                        <div class="btn-group">
                            <a href="{% url 'addting' %}">
                                <input class="btn btn-success"  type="button" value="添加">
                            </a>
                        </div>
                    </div>
                    <div id="example2_wrapper" class="dataTables_wrapper form-inline" role="grid">
                        <div class="row">
                            <div class="span6">
                            </div>
                        </div>
                        <table cellpadding="0" cellspacing="0" border="0" class="table table-hover table table-striped table-bordered dataTable" id="example2" aria-describedby="example2_info">
                            <thead>
                            <tr role="row">
                                <th class="sorting_asc" role="columnheader" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-sort="ascending" aria-label="Rendering engine: activate to sort column descending" style="width: 168px;">所属项目</th>
                                <th class="sorting_asc" role="columnheader" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-sort="ascending" aria-label="Rendering engine: activate to sort column descending" style="width: 168px;">任务名称</th>
                                <th class="sorting_asc" role="columnheader" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-sort="ascending" aria-label="Rendering engine: activate to sort column descending" style="width: 168px;">任务用例</th>
                                <th class="sorting_asc" role="columnheader" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-sort="ascending" aria-label="Rendering engine: activate to sort column descending" style="width: 168px;">执行时间</th>
                                <th class="sorting" role="columnheader" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending" style="width: 233px;">创建者</th>
                                <th class="sorting" role="columnheader" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending" style="width: 214px;">操作</th>
                            </thead>
                            <tbody role="alert" aria-live="polite" aria-relevant="all">
                            {% for project in timingtasks %}
                            <tr class="gradeA odd" id="{{ project.id }}">
                      {%if project == None%}
                            <p style="    color: red;"> 你所属于的项目是不是没有测试任务，你可以选择去添加所属的项目的测试任务</p>
                            {%else%}
                                <tr class="gradeA odd">
                                  <td class=" sorting_1">{{ project.prject }}</td>
                                    <td class=" sorting_1">{{ project.name }}</td>
                                    <td class=" sorting_1">{% for case in project.case.all %} {{ case.casenum }}、{% endfor %}</td>
                                    <td class=" sorting_1">{{ project.taskstart }}</td>
                                    <td class=" ">{{ project.makeuser }}</td>
                                    <td class=" ">
                                        <a href="{% url 'edittiming' id=project.id %}">
                                            <button class="btn btn-primary ">
                                                <i class="icon-pencil icon-white"></i>编辑
                                            </button>
                                        </a>
                                            <button class="btn btn-danger " onclick="deletetimingtask({{ project.id }})">
                                                <i class="icon-remove icon-white"></i>
                                                删除
                                            </button>
                                    </td>
                                </tr>
                                {%endif%}
                            {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
{% block js %}
    function deletetimingtask(id) {
    $.ajax({
    url:'{% url 'tingtask' %}',
    type:'DELETE',
    data:id,
    contentType: 'application/json; charset=UTF-8',
    processData:false,
    success:function(data){
    if(data['code']!=2){
    alert(data['data'])
    }else{
    alert(data['data'])
    caseid=document.getElementById(id);
    caseid.hidden=true;
    }
    }
    })
    }
{% endblock %}
